abstract class Data {
    abstract public void DisplayValue();
}
class Integer extends  Data {
    int value;
    Integer() {
        value=100;
    }
    @Override
    public void DisplayValue(){
        System.out.println (value);
    }

    @Override
    public String toString() {    //重构
        return "value=" + value ;
    }
}
class Byte extends  Data {

    byte value;
    Byte() {
        value=1;
    }
    @Override
    public void DisplayValue(){
        System.out.println (value);
    }

    @Override
    public String toString() {      //重构
        return "value=" + value ;
    }

}
// Pattern Classes
abstract class Factory {
    abstract public Data CreateDataObject();
}

class IntFactory extends Factory {
    @Override
    public Data CreateDataObject(){
        return new Integer();
    }
}
class ByteFactory extends Factory {
    @Override
    public Data CreateDataObject(){
        return new Byte();
    }
}
//Client classes
class Document {
    private Data pd;
    Document(Factory pf){
        pd = pf.CreateDataObject();
    }
    public void getPd() {           //重构
        pd.DisplayValue();
    }

    public void setPd(Data pd) {            //重构
        this.pd = pd;
    }


}
//Test class
public class MyDoc {
    static Document d;
    public static void main(String[] args) {
        d = new Document(new ByteFactory());
        d.getPd();  //重构
    }
}